package fashionshop.gui_old;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import fashionshop.utility.DatePicker;

public class TestDatePicker {

	private JFrame frame;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TestDatePicker window = new TestDatePicker();
					window.frame.setVisible(true);
					
//					b.addActionListener(new ActionListener() {
//				        public void actionPerformed(ActionEvent ae) {
//				            text.setText(new DatePicker(f).setPickedDate());
//				        }
//				    });
				} catch (Exception e) {
					e.printStackTrace();
				}
				
			}
		});
	}

	/**
	 * Create the application.
	 */
	public TestDatePicker() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		frame.getContentPane().add(panel, BorderLayout.CENTER);
		
		JLabel lblNewLabel = new JLabel("New label");
//		lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
//		lblNewLabel.setVerticalAlignment(SwingConstants.TOP);
		panel.add(lblNewLabel);
		
		lblNewLabel.setLocation(0, 0);
		textField = new JTextField();
		textField.disable();
		panel.add(textField);
		textField.setColumns(10);
		
//		final JFrame f = new JFrame();
//	    f.getContentPane().add(panel);
//	    f.pack();
//	    f.setVisible(true);
	    
		JButton btnNewButton = new JButton("New button");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				DatePicker dp = new DatePicker(frame);
//                Point bP = btnNewButton.getLocationOnScreen();
//                dp.d.setLocation(bP.x, bP.y + btnNewButton.getHeight()); 
//                dp.d.setVisible(true);
				textField.setText(dp.setPickedDate());
	        }
		});
		panel.add(btnNewButton);
	}
}
